<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>内部管理系统</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link rel="stylesheet" type="text/css"
	href="../../lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
	href="../../stylesheets/theme.css">
<link rel="stylesheet"
	href="../../lib/font-awesome/css/font-awesome.css">

<script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<script src="../../js/init.js"></script>	

<link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
	
<!-- <script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../js/init.js"></script>
<script src="../../lib/jquery.messager.js"></script>
 -->

<style type="text/css">
#container {
	height: 300px;
	width: 400px;
}

.fl {
	float: left
}

select {
	width: 130px;
}
.title{
	font-size:18px;
	font-weight:bold;
}
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="lib/html5.js"></script>
    <![endif]-->
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body class="">
	<!--<![endif]-->

	<div class="navbar"></div>
	<div class="common"></div>

	<div class="sidebar-nav"></div>

	<div class="content">
		<div class="well">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#userlist" data-toggle="tab">个人</a></li>
			</ul>
			<div id="myTabContent" class="tab-content">
				<div class="tab-pane active in" id="storelist">

					<div class="container-fluid">
						<div class="span8">
							<form class="form-horizontal" id="user_form">
								<div class="control-group title">详情 </div>
								<input type="hidden" id="personId">
								<input type="hidden" id="provinceId_hidden">
								<input type="hidden" id="cityId_hidden">
								<input type="hidden" id="districtId_hidden">
								<input type="hidden" id="dicFieldId_hidden">
								<input type="hidden" id="universityId_hidden">
								<input type="hidden" id="dicEducationId_hidden">
								<table class="table">
									<tr>
										<td><label class="control-label">姓名：</label></td>
										<td>
											<label id="personName"></label>
											<input type="text"  id="personName_input" name="personName_input" placeholder="姓名">
										</td>
										<td><label class="control-label">性别：</label></td>
										<td><label id="personGender"></label>
											<input name="personGender" type="radio" value="1" />男 
											<input name="personGender" type="radio" value="0" />女 
										</td>
									</tr>
									<tr>
										<td><label class="control-label">电话：</label></td>
										<td>
											<label id="tel"></label>
											<input type="text"  id="tel_input" name="tel_input" placeholder="电话">
										</td>
										<td><label class="control-label">邮箱地址：</label></td>
										<td>
											<input type="text"  id="email" name="email" placeholder="邮箱地址">
										</td>
									</tr>
									<tr>
										<td><label class="control-label">求职类型：</label></td>
										<td>
											<input name="postFlag" type="radio" value="2" />兼职 
											<input name="postFlag" type="radio" value="1" />实习 
										</td>
										<td><label class="control-label">求职领域：</label></td>
										<td>
											<select name="dicFieldId" id="dicFieldId"></select>
										</td>
									</tr>
									<tr>
										<td><label class="control-label">所在地区：</label></td>
										<td>
											<select name="provinceId" id="provinceId" onchange="loadCityAndUniversity()"></select>
											<select name="cityId" id="cityId" onchange="loadDistrict()"></select>
											<select name="districtId" id="districtId"></select>
										</td>
										<td><label class="control-label">大学：</label></td>
										<td>
											<select name="universityId" id="universityId" ></select>
										</td>
									</tr>
									<tr>
										<td><label class="control-label">学院：</label></td>
										<td>
											<input type="text" id="college" name="college" placeholder="学院">
										</td>
										<td><label class="control-label">专业：</label></td>
										<td>
											<input type="text" id="major" name="major" placeholder="专业">
										</td>
									</tr>
									<tr>
										<td><label class="control-label">入学时间：</label></td>
										<td>
											<input type="text" id="admissionDate"  placeholder="MM/dd/yyyy">
										</td>
										<td><label class="control-label">学历：</label></td>
										<td>
											<select name="dicEducationId" id="dicEducationId" ></select>
										</td>
									</tr>
									<tr>
										<td><label class="control-label">生日：</label></td>
										<td>
											<input type="text" id="birthday" placeholder="MM/dd/yyyy">
										</td>
										<td><label class="control-label">自我评价：</label></td>
										<td>
											<input type="text" id="selfEvaluation" name="selfEvaluation" placeholder="专业">
										</td>
									</tr>
									
								</table>

								<div class="form-actions">
									<button id="btn-back" type="button" class="btn ">返回</button>
									<button id="btn-save" type="button" class="btn ">保存</button>
								</div>

							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


	<script type="text/javascript">
	
		//初始化导航栏
		$(function() {
			initAdminNavBar();
			initCommon();
			initSideBar('user-management', 'person-list');
			$("#admissionDate").datepicker();
			$("#birthday").datepicker();
			
			

		});
		
		//初始化页面信息
		function onload(){
			var personId = $('#personId').val();
			
			if (personId != null && personId != "") {//更新的情况下,给页面赋初始值
				 $('#personName_input').hide();
				 $('#tel_input').hide();
			}else{//新增
				$('#personName').hide();
				$('#tel').hide();
				$(":radio[name=postFlag][value=1]").attr("checked",false);
				$(":radio[name=postFlag][value=2]").attr("checked",true);
				$(":radio[name=personGender][value=1]").attr("checked",true);
				$(":radio[name=personGender][value=0]").attr("checked",false);
			}

			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectDistrictList.json?level=1",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicDistrictId
									+ "'>" + data.responseData[int].dicDistrict
									+ "</option> ";
						}
						$('#provinceId').html(options);
						var provinceId_hidden = $('#provinceId_hidden').val();
						$("#provinceId").val(provinceId_hidden); 
					}
				}
			});
			var provinceId_hidden = $('#provinceId_hidden').val();
			if(provinceId_hidden != null && provinceId_hidden != ""){
				loadCityAndUniversity(provinceId_hidden);
			}
			var cityId_hidden = $('#cityId_hidden').val();
			if(cityId_hidden != null && cityId_hidden != ""){
				loadDistrict(cityId_hidden);
			}
		}
		function loadCityAndUniversity(provinceId_hidden){//
			var provinceId = $('#provinceId').val();
			if(provinceId == null || provinceId == ""){
				provinceId = provinceId_hidden;
			}
		     $("#cityId").empty();
		     $("#districtId").empty();
		     $("#universityId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=2&parentId=" + provinceId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#cityId').html(options);
							var cityId_hidden = $('#cityId_hidden').val();
							$("#cityId").val(cityId_hidden);
						}
					}
				});
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/searchUniversity.json?university=&dicDistrictId=" + provinceId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicUniversityId
								+ "'>" + data.responseData[int].dicUniversityName
										+ "</option> ";
							}
							$('#universityId').html(options);
							var universityId_hidden = $('#universityId_hidden').val();
							$("#universityId").val(universityId_hidden);
						}
					}
				});
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectEducation.json",
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicEducationId
								+ "'>" + data.responseData[int].dicEducationName
										+ "</option> ";
							}
							$('#dicEducationId').html(options);
							var dicEducationId_hidden = $('#dicEducationId_hidden').val();
							$("#dicEducationId").val(dicEducationId_hidden);
						}
					}
				});
		}
		
		function loadDistrict(cityId_hidden){
			var cityId = $('#cityId').val();
			if(cityId == null || cityId == ""){
				cityId = cityId_hidden;
			}
		     $("#districtId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=3&parentId=" + cityId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#districtId').html(options);  
							var districtId_hidden = $('#districtId_hidden').val();
							$("#districtId").val(districtId_hidden);
						}
					}
				});
		}
		
		$(function(){
		       $("input[name='postFlag']").click(function(){
		    	   loadField();
		       });
		     });
		function loadField(){
			var postFlag = $("input[name='postFlag']:checked").val();
			if(postFlag == 1){//实习
				$.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectInternshipField4Page.json",
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicFieldId
										+ "'>" + data.responseData[int].dicFieldName
										+ "</option> ";
							}
							$('#dicFieldId').html(options);
							var dicFieldId_hidden = $('#dicFieldId_hidden').val();
							$("#dicFieldId").val(dicFieldId_hidden);
						}
					}
				});	
			}else if(postFlag == 2){//兼职
				$.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectParttimeField.json",
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicFieldId
										+ "'>" + data.responseData[int].dicFieldName
										+ "</option> ";
							}
							$('#dicFieldId').html(options);
							var dicFieldId_hidden = $('#dicFieldId_hidden').val();
							$("#dicFieldId").val(dicFieldId_hidden);
						}
					}
				});
			}
			
		}
		
		//初始化用户详细信息
		$(function() {
			var personId = getparastr('personId');
			$("#personId").val(personId);
			if (personId != null && personId != "") {//更新的情况下,给页面赋初始值
				$.ajax({
					contentType : "application/json",
					url : api_base_url
							+ "selectPersonDetail.json?personId="
							+ personId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var personName = data.responseData.personName;
							var personGender = data.responseData.personGenderInput;
							var birthday = data.responseData.birthday;
							var tel = data.responseData.tel;
							var email = data.responseData.email;
							var provinceId = data.responseData.provinceId;
							var cityId = data.responseData.cityId;
							var districtId = data.responseData.districtId;
							var postFlag = data.responseData.postFlagInput;
							var dicFieldId = data.responseData.dicFieldId;
							var universityId = data.responseData.universityId;
							var college = data.responseData.college;
							var major = data.responseData.major;
							var admissionDate = data.responseData.admissionDate;
							var dicEducationId = data.responseData.dicEducationId;
							var selfEvaluation = data.responseData.selfEvaluation;
							$("#personName").html(personName);
							if(personGender == 0){//女
								$(":radio[name=personGender][value=0]").attr("checked",true);
								$(":radio[name=personGender][value=1]").attr("checked",false);
							}else{
								$(":radio[name=personGender][value=0]").attr("checked",false);
								$(":radio[name=personGender][value=1]").attr("checked",true);
							}
							$("#personGender").val(personGender);
							$("#birthday").val(birthday);
							$("#tel").html(tel);
							$("#email").val(email);
							$("#provinceId_hidden").val(provinceId);
							$("#cityId_hidden").val(cityId);
							$("#districtId_hidden").val(districtId);
							$("#postFlag").val(postFlag);
							if(postFlag == 1){//实习
								$(":radio[name=postFlag][value=1]").attr("checked",true);
								$(":radio[name=postFlag][value=2]").attr("checked",false);
							}else{//兼职
								$(":radio[name=postFlag][value=1]").attr("checked",false);
								$(":radio[name=postFlag][value=2]").attr("checked",true);
							}
							$("#dicFieldId_hidden").val(dicFieldId);
							$("#universityId_hidden").val(universityId);
							$("#college").val(college);
							$("#major").val(major);
							$("#admissionDate").val(admissionDate);
							$("#dicEducationId_hidden").val(dicEducationId);
							$("#selfEvaluation").val(selfEvaluation);
							onload();
							loadField()
						}
						$.messager.anim('fade', 1000);
					    $.messager.show('操作提示',data.msg, 5000);
					}
				});
			}  else{
				onload();
				loadField()
			}

		});


		//返回
		$('#btn-back').on('click', function() {
			history.back()
		});
		
		//保存
		$('#btn-save').on('click', function() {
			var personId = $('#personId').val();
			var personName = $('#personName').html();
			var tel = $('#tel').html();
			if (personId == null || personId == "") {//更新的情况下,给页面赋初始值
				personName = $('#personName_input').val();
				tel = $('#tel_input').val();////
			}else{
				personName = $('#personName').html();
				tel = $('#tel').html();
			}
			var personGender = $("input[name='personGender']:checked").val();
			var email = $('#email').val();
			var postFlag = $("input[name='postFlag']:checked").val();
			var dicFieldId = $('#dicFieldId').val();
			var districtId = $('#districtId').val();//
			var universityId = $('#universityId').val();
			var college = $('#college').val();
			var major = $('#major').val();
			var admissionDate = $('#admissionDate').val();
			var dicEducationId = $('#dicEducationId').val();
			var birthday = $('#birthday').val();
			var selfEvaluation = $('#selfEvaluation').val();
			
			$.ajax({
				contentType : "application/json",
				url : api_base_url
						+ "editPerson.json?personId=" + personId
						+ "&personName=" + personName
						+ "&tel=" + tel
						+ "&personGender=" + personGender
						+ "&email=" + email
						+ "&postFlag=" + postFlag
						+ "&dicFieldId=" + dicFieldId
						+ "&districtId=" + districtId
						+ "&universityId=" + universityId
						+ "&college=" + college
						+ "&major=" + major
						+ "&admissionDate=" + admissionDate
						+ "&dicEducationId=" + dicEducationId
						+ "&birthday=" + birthday
						+ "&selfEvaluation=" + selfEvaluation,
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						window.location.href="../usermanagement/personlist.html";
					}else{
						$.messager.anim('fade', 1000);
					    $.messager.show('操作提示',data.msg, 5000);
					}
				}
			});
		});

	</script>

</body>
</html>


